<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}AI学习智能体门户{% endblock %}</title>
    
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    
    {% block extra_css %}{% endblock %}
    
    <style>
        .navbar-brand {
            font-weight: bold;
            color: #007bff !important;
        }
        .footer {
            background-color: #f8f9fa;
            margin-top: auto;
        }
        body {
            display: flex;
            flex-direction: column;
            min-height: 100vh;
        }
        .main-content {
            flex: 1;
        }
        .sidebar {
            min-height: calc(100vh - 56px);
            background-color: #f8f9fa;
        }
        .card {
            transition: all 0.3s ease;
        }
        .card:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        }
    </style>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-light bg-light border-bottom">
        <div class="container-fluid">
            <a class="navbar-brand" href="{% url 'users:home' %}">
                <i class="fas fa-robot me-2"></i>AI学习智能体门户
            </a>
            
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="{% url 'users:home' %}">
                            <i class="fas fa-home me-1"></i>首页
                        </a>
                    </li>
                    {% if user.is_authenticated %}
                    <li class="nav-item">
                        <a class="nav-link" href="{% url 'users:dashboard' %}">
                            <i class="fas fa-tachometer-alt me-1"></i>仪表板
                        </a>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">
                            <i class="fas fa-robot me-1"></i>智能体
                        </a>
                        <ul class="dropdown-menu">
                            <li><a class="dropdown-item" href="#">我的智能体</a></li>
                            <li><a class="dropdown-item" href="#">创建智能体</a></li>
                            <li><a class="dropdown-item" href="#">智能体市场</a></li>
                        </ul>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">
                            <i class="fas fa-graduation-cap me-1"></i>学习
                        </a>
                        <ul class="dropdown-menu">
                            <li><a class="dropdown-item" href="#">我的课程</a></li>
                            <li><a class="dropdown-item" href="#">课程目录</a></li>
                            <li><a class="dropdown-item" href="#">学习进度</a></li>
                        </ul>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">
                            <i class="fas fa-book me-1"></i>知识库
                        </a>
                        <ul class="dropdown-menu">
                            <li><a class="dropdown-item" href="#">我的知识库</a></li>
                            <li><a class="dropdown-item" href="#">文档管理</a></li>
                            <li><a class="dropdown-item" href="#">知识搜索</a></li>
                        </ul>
                    </li>
                    {% endif %}
                </ul>
                
                <ul class="navbar-nav">
                    {% if user.is_authenticated %}
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">
                            {% if user.avatar %}
                                <img src="{{ user.avatar.url }}" alt="头像" class="rounded-circle me-1" width="24" height="24">
                            {% else %}
                                <i class="fas fa-user-circle me-1"></i>
                            {% endif %}
                            {{ user.get_full_name|default:user.username }}
                        </a>
                        <ul class="dropdown-menu dropdown-menu-end">
                            <li><a class="dropdown-item" href="#">个人资料</a></li>
                            <li><a class="dropdown-item" href="#">设置</a></li>
                            <li><hr class="dropdown-divider"></li>
                            <li><a class="dropdown-item" href="{% url 'users:logout' %}">退出登录</a></li>
                        </ul>
                    </li>
                    {% else %}
                    <li class="nav-item">
                        <a class="nav-link" href="{% url 'users:login' %}">登录</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{% url 'users:register' %}">注册</a>
                    </li>
                    {% endif %}
                </ul>
            </div>
        </div>
    </nav>

    <!-- 消息提示 -->
    {% if messages %}
    <div class="container-fluid mt-2">
        {% for message in messages %}
        <div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
            {{ message }}
            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
        </div>
        {% endfor %}
    </div>
    {% endif %}

    <!-- 主要内容 -->
    <main class="main-content">
        {% block content %}{% endblock %}
    </main>

    <!-- 页脚 -->
    <footer class="footer py-4 mt-5">
        <div class="container">
            <div class="row">
                <div class="col-md-6">
                    <h5>AI学习智能体门户</h5>
                    <p class="text-muted">让AI助力您的学习之旅</p>
                </div>
                <div class="col-md-3">
                    <h6>快捷链接</h6>
                    <ul class="list-unstyled">
                        <li><a href="#" class="text-muted">关于我们</a></li>
                        <li><a href="#" class="text-muted">帮助中心</a></li>
                        <li><a href="#" class="text-muted">联系我们</a></li>
                    </ul>
                </div>
                <div class="col-md-3">
                    <h6>社交媒体</h6>
                    <div>
                        <a href="#" class="text-muted me-3"><i class="fab fa-github"></i></a>
                        <a href="#" class="text-muted me-3"><i class="fab fa-twitter"></i></a>
                        <a href="#" class="text-muted me-3"><i class="fab fa-linkedin"></i></a>
                    </div>
                </div>
            </div>
            <hr>
            <div class="text-center text-muted">
                <small>&copy; 2024 AI学习智能体门户. 保留所有权利.</small>
            </div>
        </div>
    </footer>

    <!-- Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    {% block extra_js %}{% endblock %}
</body>
</html>